import java.util.Random;

public class Question03 {
    public static void main(String[] args) {
        Random random = new Random();
        int[] arr = new int[20];
        int b = 0;
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(20);
            System.out.print(arr[i]);
            if (i != arr.length - 1) {
                //只要不是最后一个数组,就加上逗号
                System.out.print(",");
            }
            if (arr[i] > 10) {
                b = b + 1;//每发现一个符合条件的数,长度就加一¬
            }
        }
        System.out.print("]");
        System.out.println();
        int[] arr1 = new int[b];
        int c = 0;//现在要给新数组哪个位置进行赋值
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > 10) {
                arr1[c] = arr[i];//arr1[c++]=arr[i];
                c = c + 1;//c++
            }
        }
        for (int i = 0; i < arr1.length; i++) {
            System.out.print(arr1[i]+",");
        }
    }
}
